
const { resolve } = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
// 单独抽离出来css文件
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

// 压缩css文件
const OptimizeCssAssetsWebpackPlugin = require("optimize-css-assets-webpack-plugin");

module.exports = {
    // entry: "./src/index.js",  单页面应用配置
    // 多入口方式拆分文件
    entry: {
        // 多页面应用配置
        main: "./src/index.js",
        test: "./src/js/test.js"
    },
    output: {
        filename: "[name].[hash:5].js",
        path: resolve(__dirname, "build")
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: "./src/index.html",
            minify: {
                collapseWhitespace: true,
                removeComments: true
            }
        }),
        new OptimizeCssAssetsWebpackPlugin()
    ],
    mode: "production"
}

/**
 * 
 * 
 * 
 */